﻿using ElectronicShoppingMall.Service.Models.Enterprise;
using ElectronicShoppingMall.Service.Services.Enterprise;
using Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace ElectronicShoppingMall.Web.Back.Controllers
{
    public class SystemsAnalysisController : ApiController
    {
        SystemsAnalysisService _service = new SystemsAnalysisService();
        //销售情况
        [System.Web.Mvc.Authorize]
        [System.Web.Mvc.HttpGet]
        public List<int> GetSalesSituation()
        {
            try
            {
                return _service.GetSalesSituation();
            }
            catch
            {
                return null;
            }
        }
        //各类销售情况
        [System.Web.Mvc.Authorize]
        [System.Web.Mvc.HttpGet]
        public List<int> GetSalesByCategory()
        {
            try
            {
                return _service.GetSalesByCategory();
            }
            catch
            {
                return null;
            }
        }
        //用户活跃度
        [System.Web.Mvc.Authorize]
        [System.Web.Mvc.HttpGet]
        public List<int> GetUserActivity()
        {
            try
            {
                string auth = Request.Headers.Authorization.ToString();
                return _service.GetUserActivity(ExtensionMethods.GetEmployeeUserObject(auth).EmployeeId);
            }
            catch
            {
                return null;
            }
        }
        //获取用户一周内的每天登陆情况
        public List<int> GetLoginSituation()
        {
            try
            {
                string auth = Request.Headers.Authorization.ToString();
                return _service.GetLoginSituation(ExtensionMethods.GetEmployeeUserObject(auth).EmployeeId);
            }
            catch
            {
                return null;
            }
        }
    }
}
